<!-- 添加好友模块 -->
<!-- <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> -->
<div class="modal-dialog" id="addWindow">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">添加好友</h3>
		</div>
		<div class="modal-body">
			<table class="table table-bordered table-striped">
				<tr>
					<td>
						<div class="input-group">
							<input type="text" class="form-control" v-model="findText" @keyup.enter="getRecoList()" placeholder="用户Id或昵称">
							<span class="input-group-btn">
								<button class="btn btn-default" style="height: 34;" type="button" @click="getRecoList()">
									<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
								</button>
							</span>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="m-list" style="height: 400px;">
							<ul>
								<!--v-for-start-->
								<!-- style="border-bottom: 1px solid #ccc;" -->
								<li class="add_li" v-for="user in list">
									<div style="float: left; padding-right: 10px;">
										<img style="width: 50px; height: 50px;" :src="user.uimage">
									</div>
									<div style="float: right; margin-top: 8px;">
										<button class="btn btn-success" :disabled="user.state ? 'disabled' : false" @click="regFriend(user.uid)"
										 v-text="user.state ? '等待回应' : '申请好友'"></button>
									</div>
									<span style="font-size: 18px;" class="add_nickName" v-text="user.nickName"></span><br />
									<span style="color: #ccc;">uid:<span class="add_uid" v-text="user.uid"></span></span>
								</li>
								<!--v-for-end-->
							</ul>
						</div>
					</td>
				</tr>

			</table>
		</div>
		<div class="modal-footer">
			<!-- <button class="btn btn-success" id="addSubmit" data-dismiss="modal" aria-hidden="true">保存</button> -->
			<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>
	</div>
</div>
<!-- </div> -->

<script>
	var addWindow = new Vue({
		el: "#addWindow",
		data: {
			//列表集合
			list: [],
			//页数
			page: 1,
			//每页数量
			size: 10,
			findText: ""
		},
		methods: {
			//获得推荐好友
			getRecoList() {
				getRecoList(this.page, this.size, this.findText).then(res => {
					if (res.data.errno == 0) {
						this.list = res.data.data;
					}
					//获取当前正在申请的好友
					return already();
				}).then(res => {
					if (res.data.errno == 0) {
						var map = res.data.data;
						this.list.forEach(li => {
							map.forEach(ad => {
								if (ad.receiveUid == li.uid) {
									li.state = ad.state;
								}

							});
						})
					}
					errInfo(res);
				})
			},
			//申请好友
			regFriend(uid) {
				addFriends(uid).then(res => {
					errInfo(res, true);
					this.getRecoList();
				})
			}
		}
	})

</script>